package com.jsg.sl651.entity.frame;

import com.jsg.sl651.entity.frame.body.MessageBody;
import com.jsg.sl651.entity.frame.header.MessageHeader;
import com.jsg.sl651.enums.CommunicationMessageType;
import com.jsg.sl651.enums.ControlCharacterDefinition;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;


/**
 * SL651帧消息封装
 */
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Accessors(chain = true)
public class FrameMessageWrapper {

    // 帧开始符号
    private final static ControlCharacterDefinition frameStartSymbol = ControlCharacterDefinition.SOH;

    // 报文的编码格式
    private CommunicationMessageType messageType;

    // 消息头信息
    private MessageHeader header;

    // 原始数据 【消息体 预留处理分包信息】
    private byte[] bodyData;

    // 解析过的消息体
    private MessageBody body;

    // 正文结束符
    private ControlCharacterDefinition endOfTextSymbol;

    // CRC校验码 只是两个字节
    private int crc;


    public byte[] getStartSymbolBytes() {
        return frameStartSymbol.getMessageBytes(messageType);
    }

}
